import 'package:flutter/material.dart';
import 'package:sticky_headers/sticky_headers.dart';

class TextPage extends StatefulWidget {
  const TextPage({Key? key}) : super(key: key);

  @override
  _TextPageState createState() => _TextPageState();
}

class _TextPageState extends State<TextPage> {
  ScrollController? controller;

  @override
  Widget build(BuildContext context) {
    final Object? product = ModalRoute.of(context)!.settings.arguments;
    // print('哈哈哈哈哈 + ${product}');

    return Scaffold(
      appBar: AppBar(
        title: Text('哈哈哈'),
      ),
      body: ListView.builder(
        primary: controller == null,
        controller: controller,
        itemCount: 10,
        itemBuilder: (context, index) {
          return StickyHeader(
            controller: controller, // Optional
            header: Container(
              height: index == 0 ? 0.0 : 50.0,
              color: Colors.blueGrey[700],
              padding: EdgeInsets.symmetric(horizontal: 16.0),
              alignment: Alignment.centerLeft,
              child: Text(
                'Header #$index',
                style: const TextStyle(color: Colors.white),
              ),
            ),
            content: Container(
              height: 200,
              color: Colors.redAccent,
            ),
          );
        },
      ),
    );
  }
}
